<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

	<h:head>
		<title>Cadastro de Usuário</title>
	</h:head> 
	<h:body> 
		<h1>Cadastro de Usuário</h1>
		<h:form>
			<h:messages />
			<h:inputHidden value="#{usuarioBean.usuario.codigo}" />
			<h:inputHidden value="#{usuarioBean.usuario.ativo}" />
			<h:inputHidden value="#{usuarioBean.destinoSalvar}" />
			
			<h:panelGrid columns="2">
				<h:outputLabel value="Nome:" for="nome" />
				<h:inputText id="nome" label="Nome" value="#{usuarioBean.usuario.nome}" required="true" size="30" maxlength="30"
							 requiredMessage="Você não tem nome???">
							 <f:validateLength minimum="10"  maximum="30"/>
				</h:inputText>
				
				<h:outputLabel value="e-Mail:" for="email" />
				<h:panelGroup>
					<h:inputText value="#{usuarioBean.usuario.email}" label="e-Mail" id="email" size="50" maxlength="50" required="true"
								 validatorMessage="e-Mail invalido!">
								 <f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+"/>
				    </h:inputText>
					<h:message for="email"/>
				</h:panelGroup>
				
								
				
				<h:outputLabel value="Login:" for="login" />
				<h:inputText id="login" label="Login" value="#{usuarioBean.usuario.login}" required="true" size="15" maxlength="15" 
							 validatorMessage="Login deve ter no minimo 5 e no maximo 15 caracteres e só pode ser os simbulos '.' e '_'.">
							 <f:validateRegex pattern="([a-z]|[0-9]|[:]|[_]){5,15}" />
				</h:inputText>
				
				<h:outputLabel value="Senha:" for="senha" />
				<h:inputSecret id="senha" label="Senha" value="#{usuarioBean.usuario.senha}" required="true" size="10" 
							   maxlength="10" redisplay="true" />
			
				<h:outputLabel value="Confiramar Senha:" for="confirmasenha" />
				<h:inputSecret id="confirmasenha" label="Confirmar Senha" value="#{usuarioBean.confirmaSenha}" required="true" size="10" 
							   maxlength="10" redisplay="true" />
			</h:panelGrid>
			
			<h:commandButton action="#{usuarioBean.salvar}" value="Salvar" />
			
		</h:form>
		<hr />
		
	</h:body> 
</html>
